#!/bin/bash

# 定义变量方便修改
table_db=cy_database 
hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else 
	do_date=`date -d "-1 day" +%F`  
fi 

sql="
with
tmp_enterprise_position_require_detail as(
	select
		id,
		ent_id,
		ent_name,
		industry_code,
		business_code,
		business_nature_code,
		industry_type,
		business_type,
		business_nature,
		posts_name,
		function_type,
		posts,
		sex,
		experience,
		education,
		salary,
		age_range,
		job_nature,
		description,
		keyword,
		keyword_two,
		keyword_three,
		province_code,
		city_code,
		area_code,
		street_code,
		province,
		city,
		area,
		street,
		address,
		latitude,
		longitude,
		status,
		views,
		publish,
		skill,
		sys_area_code,
		batchNumber,
		age_begin,
		age_end,
		salary_begin,
		salary_end,
		source,
		update_time
	from cy_database.dwd_enterprise_position_require_detail eprd
	where eprd.dt='2020-06-17' and eprd.id is not null

)
insert overwrite table cy_database.dws_enterprise_position_require_detail partition(dt='2020-06-17')
	select
		id,
		ent_id,
		ent_name,
		industry_code,
		business_code,
		business_nature_code,
		industry_type,
		business_type,
		business_nature,
		posts_name,
		function_type,
		posts,
		sex,
		experience,
		education,
		salary,
		age_range,
		job_nature,
		description,
		keyword,
		keyword_two,
		keyword_three,
		province_code,
		city_code,
		area_code,
		street_code,
		province,
		city,
		area,
		street,
		address,
		latitude,
		longitude,
		status,
		views,
		publish,
		skill,
		sys_area_code,
		batchNumber,
		age_begin,
		age_end,
		salary_begin,
		salary_end,
		source,
		update_time
	from tmp_enterprise_position_require_detail

;



"
$hive -e "$sql"